#!/usr/bin/env python
# -*- encoding: utf-8 -*-
# Project: spd-sxmcc
"""
@author: lyndon
@time Created on 2018/12/24 13:59
@desc
"""

import os
import requests
from bs4 import BeautifulSoup

user_agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36"
headers = {"User-Agent": user_agent}  # 请求头,headers是一个字典类型
url_pre = 'https://ty.5i5j.com'
with open(r"D:\iProject\myPython\com\teradata\laccelllatitude\wiwj_detail.txt", 'r') as f:
    soup = BeautifulSoup(f, "lxml")
    apartment = {}
    apartment['lll'] = [s.text.encode('utf-8').replace('\n', '') for s in soup.select('li') if '房屋总数：' in s.encode('utf-8')]

    print(apartment['lll'])
    for al in apartment['lll']:
        print(al)
    # apartment['build_time'] = [ll.text.encode('utf-8').replace('\n', '').replace(' ', '').strip() for ll in li.select("p")]
    # url_detail = url_pre + apartment['url']
    # res = requests.get(url_detail, headers=headers)
    # res.encoding = "utf-8"  # 设置编码，防止乱码
    # soup2 = BeautifulSoup(res.text, "html")
    #
    # apartment['lous'] = [li.text.strip() for li in soup2.select('li') if '楼栋总数' in li.text.encode('utf-8').strip()]
    # apartment['fangs'] = [li.text.strip() for li in soup2.select('li') if '房屋总数' in li.text.encode('utf-8').strip()]

